package com.zlm.tools.controller;

import com.zlm.custom.spring.ApplicationContext;
import com.zlm.tools.event.RegisterEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

/**
 * {@code }
 *
 * @author zlm
 * @since 2025/5/29
 */

@RestController
@RequestMapping("/user")
public class LoginController {



    @Autowired
    private ApplicationEventPublisher publisher;

    @Autowired
    private ApplicationEventMulticaster  multicaster;


    @PostConstruct
    public void init() {
        System.out.println("LoginController init");
    }

    @RequestMapping("/register")
    public String login(String username) {
        System.out.println("用户注册了");
        publisher.publishEvent(new RegisterEvent(username));
        return "ok";
    }
}
